#pragma once
#include <map>
#include <vector>
#include <string>
#include "Singleton.h"


struct TextureData
{
	Microsoft::WRL::ComPtr<ID3D11Texture2D>             texture;                    
	Microsoft::WRL::ComPtr<ID3D11ShaderResourceView>    textureShaderResourceView; 
};

class RenderObject;
class Sprite;
ref class RenderObjectManager: public SingletonRef<RenderObjectManager>
{
	friend SingletonRef;
internal:
	enum RenderObjectLayer
	{
		RenderObjectLayer0 = 0,
		RenderObjectLayer1,
		RenderObjectLayer2,
		RenderObjectLayer3,
		RenderObjectLayerNum
	};
	
private:
	RenderObjectManager();

	~RenderObjectManager();

	void CleanUpTexture();

	void CleanUpRenderObject();

	std::map<uint, std::shared_ptr<RenderObject>>		m_RenderSpriteMap;

	std::vector<RenderObject*>							m_RenderLayer[RenderObjectLayerNum];

	std::map<std::wstring, TextureData>					m_TextureDataMap;

internal:
	void Initialize();

	Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> CreateTexture(const std::wstring& filename);

	std::shared_ptr<Sprite> CreateSprite(const std::wstring& texture = L"", const float2& position = float2(0.f, 0.f), const float2& size = float2(1.f, 1.f), float angle_deg = 0.f);

	void AddSpriteToRenderList(Sprite* s, RenderObjectLayer layer);

	void Render(ID3D11DeviceContext1* context);

	void Update(float frame_time);



};